#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <iostream>

int main () {
    using namespace boost::numeric::ublas;
    compressed_matrix<double> m (30, 30);

    typedef boost::numeric::ublas::compressed_matrix<double>::iterator1 it1_t;
    typedef boost::numeric::ublas::compressed_matrix<double>::const_iterator1 it1_t2;
    typedef boost::numeric::ublas::compressed_matrix<double>::iterator2 it2_t;
    typedef boost::numeric::ublas::compressed_matrix<double>::const_iterator2 it2_t2;

    
    for (unsigned i = 1; i < m.size1 () - 1; ++ i)
    {
	m (i, i) = 2;
	m (i, i - 1) = -1;
	m (i, i + 1) = -1;
    }
    m (0, 0) = 2;
    m (0, 1) = -1;
    m (m.size1 () - 1, m.size1 () - 1) = 2;
    m (m.size1 () - 1, m.size1 () - 2) = -1;
//    std::cout << m << std::endl;
    for (it1_t it1 = m.begin1(); it1 != m.end1(); it1++) // row
	for (it2_t it2 = it1.begin(); it2 != it1.end(); it2++) // column
	{
	    std::cout << "(" << it2.index1() << ", "
		      << it2.index2() << ", " << *it2 << ")" << std::endl;
	}
}
